from abc import ABC, abstractmethod

# 抽象产品
class AbstractProduct(ABC):
    @abstractmethod
    def operation(self):
        pass

# 具体产品1
class ConcreteProduct1(AbstractProduct):
    def operation(self):
        return "具体产品1的操作"

# 具体产品2
class ConcreteProduct2(AbstractProduct):
    def operation(self):
        return "具体产品2的操作"

# 抽象工厂
class AbstractFactory(ABC):
    @abstractmethod
    def create_product(self):
        pass

# 具体工厂1
class ConcreteFactory1(AbstractFactory):
    def create_product(self):
        return ConcreteProduct1()

# 具体工厂2
class ConcreteFactory2(AbstractFactory):
    def create_product(self):
        return ConcreteProduct2()

# 客户端代码
class Client:
    def __init__(self, factory: AbstractFactory):
        self.factory = factory
    
    def do_something(self):
        product = self.factory.create_product()
        return product.operation()

# 使用示例
def main():
    # 使用工厂1
    factory1 = ConcreteFactory1()
    client1 = Client(factory1)
    print(client1.do_something())
    
    # 使用工厂2
    factory2 = ConcreteFactory2()
    client2 = Client(factory2)
    print(client2.do_something())

if __name__ == "__main__":
    main()


# 运行结果
# 具体产品1的操作
# 具体产品2的操作